<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:acm="http://java.sun.com/jsf/composite/comp">
<ui:composition template="/templates/baseLayout.xhtml">
	<ui:define name="body">
		<f:metadata>
			<f:viewParam id="makeId" name="makeId" value="#{invCtrl.makeId}" />
			<f:viewParam id="modelId" name="modelId" value="#{invCtrl.modelId}" />
			<f:viewParam id="year" name="year" value="#{invCtrl.year}" />
			<f:viewParam id="price" name="price" value="#{invCtrl.price}" />
			<f:viewParam id="cond" name="cond" value="#{invCtrl.cond}" />
	    </f:metadata>
		<section id="content">
	    	<div class="row-2">
	      		<h3> 
	      			<h:form id="form-1">
	      				<a4j:status>
				            <f:facet name="start">
				                <h:graphicImage value="/images/loader.gif" alt="ai" style="width:24px; height:24px;"/>
				            </f:facet>
				            <f:facet name="stop">
				                <acm:spacer width="24px" height="24px"/>
				            </f:facet>
				        </a4j:status> 
	      				<h:selectOneListbox value="#{invCtrl.makeId}" size="1">
                       		<f:selectItems value="#{invCtrl.makes}"/>
                       		<f:ajax event="change" render="@all"/>
                       	</h:selectOneListbox>
                       	&nbsp;
                       	<h:selectOneListbox id="Model" value="#{invCtrl.modelId}" size="1" disabled="#{invCtrl.makeId == null}">
                       		<f:selectItems value="#{invCtrl.models}"/>
                       		<f:ajax event="change" render="@all"/>
                       	</h:selectOneListbox>
                       	&nbsp;
                       	<h:selectOneListbox id="Style" value="#{invCtrl.styleId}" size="1" disabled="#{invCtrl.modelId == null}">
                       		<f:selectItems value="#{invCtrl.styles}"/>
                       		<f:ajax event="change" render="@all"/>
                       	</h:selectOneListbox>
                       	&nbsp;
                       	<h:selectOneListbox value="#{invCtrl.year}" size="1">
                       		<f:selectItems value="#{invCtrl.years}"/>
                       		<f:ajax event="change" render="@all"/>
                       	</h:selectOneListbox>
                       	&nbsp;
                       	<h:selectOneListbox value="#{invCtrl.price}" size="1">
                       		<f:selectItems value="#{invCtrl.prices}"/>
                   			<f:ajax event="change" render="@all"/>
                       	</h:selectOneListbox>                            	                 	                       	
                   	</h:form>
                </h3>
	      		<ui:repeat var="car" value="#{invCtrl.cars}">
	      			<div class="wrapper">
		            	<figure class="img-indent"><h:graphicImage value="/img/?imgId=#{car.displayImage.imageId}" width="253" height="177"/></figure>
		                <div class="extra-box">
			                <div class="padding-top">
			                	<h4>#{car.make.name} - #{car.model.name} - #{car.style.name} <span>#{car.year}</span></h4>
			                    <h:panelGrid columns="6" columnClasses="rightAlign col-padding, leftAlign boldFont col-padding, rightAlign col-padding, leftAlign boldFont col-padding, rightAlign col-padding, leftAlign boldFont col-padding" 
			                    	width="75%" styleClass="table-1">
			                    	<h:outputText value="Engine:&nbsp;"/>
			                    	<h:outputText value="#{car.engine}"/>
			                    	<h:outputText value="Transmission: "/>
			                    	<h:outputText value="#{car.transType}" converter="enumConverter"/>
			                    	<h:outputText value="Drive Train: "/>
			                    	<h:outputText value="#{car.drvTrnType}" converter="enumConverter"/>
			                    	<h:outputText value="Body: "/>
			                    	<h:outputText value="#{car.style.bodyType}" converter="enumConverter"/>		
			                    	<h:outputText value="Exterior: "/>
			                    	<h:outputText value="#{car.colorExt}"/>
			                    	<h:outputText value="Interior: "/>
			                    	<h:outputText value="#{car.colorInt}"/>
			                    	<h:outputText value="Mileage: "/>
			                    	<h:outputText value="#{car.mileage}"/>
			                    	<h:outputText value="Price: "/>
			                    	<h:outputText value="#{car.salePrice}">
			                    		<f:convertNumber pattern="$0,000" />
			                    	</h:outputText>
			                    	<h:outputText value="VIN#: "/>
			                    	<h:outputText value="#{car.vin}"/>			                    				                    	
			                    </h:panelGrid>
			                    <br/>
			                    <h:panelGrid columns="2" width="100%">
			                    	<h:panelGroup>			                    	
					                    <h:link styleClass="button1" outcome="/pub/inq/inquire?carId=#{car.vehicleId}"><strong>Inquire</strong></h:link>					                    
					                    <acm:spacer width="10px"/>
					                    <h:link styleClass="button1" outcome="/pub/loan/loanApp?carId=#{car.vehicleId}"><strong>Need Finance</strong></h:link>
					                    <acm:spacer width="10px"/>
					                    <h:outputLink value="#{car.carfaxApprvUrl}" target="_new" styleClass="button1" rendered="#{not empty car.carfaxApprvUrl}"><strong>Carfax Approved</strong></h:outputLink>
				                    </h:panelGroup>
				                    <h:panelGroup styleClass="fright">
				                    	<a4j:commandLink styleClass="button1" oncomplete="#{rich:component('DeletePopup')}.show();" rendered="#{authorizedUser!=null}">
				                    		<strong>Delete</strong>
											<f:param name="carId" value="#{car.vehicleId}"/>
										</a4j:commandLink>										
				                    	<acm:spacer width="10px"/>
				                    	<h:link styleClass="button1" outcome="/sec/inv/invEdit?carId=#{car.vehicleId}" rendered="#{authorizedUser!=null}"><strong>Update</strong></h:link>
				                    	<acm:spacer width="10px"/>
				                    	<h:link styleClass="button1" outcome="/pub/inv/invDisplay?carId=#{car.vehicleId}&amp;backTo=Inventory"><strong>Details</strong></h:link>
				                    </h:panelGroup>
			                    </h:panelGrid>		                    
			                </div>
		                </div>
		            </div>
		            <hr/>
	      		</ui:repeat>
	      		<c:if test="#{empty invCtrl.cars}">
	      			<div class="wrapper">
		            	<div class="extra-box">
			                <div class="padding-top">
			                	<h4>We are Sorry. Could'nt find a Car of your choice</h4>
			                    <p>
			                    	Please use the <strong>Find a Car</strong> form on the menu above to submit 
			                    	your preferences, and we'll hunt down the best car in town for you.
			                    </p>			                                       
			                </div>
		                </div>
		            </div>
	      		</c:if>
	      		<rich:notifyMessages stayTime="6000" nonblocking="true" showCloseButton="true" ></rich:notifyMessages>				            
	         </div>	            
	    </section>
		<h:form id="VehicleDeleteForm" prependId="false">	
			<rich:popupPanel id="DeletePopup" modal="true" width="250" height="75" domElementAttachment="parent">
				<f:metadata>
					<f:viewParam id="carId" name="carId" value="#{invCtrl.car}" converter="entityConverter">
			        	<f:param name="entityName" value="Vehicle"/>
			        </f:viewParam>		        
			    </f:metadata>
			    <h:panelGrid columnClasses="centerAlign" width="100%" rowClasses="s1row">
			    	<h:outputLabel value="Are your sure you want to Delete this Car ?"/>
			    	<h:panelGroup>
			    		<a4j:commandLink styleClass="button1" value="Yes" action="#{invCtrl.deleteVehicle}" 
							oncomplete="#{rich:component('DeletePopup')}.hide();" render="@all">
				        </a4j:commandLink>
					    <acm:spacer width="10px;"/>	
					    <a4j:commandLink styleClass="button1" value="No" onclick="#{rich:component('DeletePopup')}.hide();"/>
				    </h:panelGroup>
			    </h:panelGrid>
			</rich:popupPanel>
		</h:form>	    	
	</ui:define>
</ui:composition>     
</html>   	